#include "sStrings.h"

namespace sgui
{

#pragma warning (push)
#pragma warning (disable : 4996)

void wstring_to_string(const std::wstring& str, char* dest)
{
	const size_t str_size = str.size();
	dest[str_size] = 0;
	wcstombs(dest, str.c_str(), str_size);
}

std::string wstring_to_string(const std::wstring& str)
{
	const size_t str_size = str.size();
	char* tmpdata = (char*)alloca(str_size + 1);
	tmpdata[str_size] = 0;
	wcstombs(tmpdata, str.c_str(), str_size);
	return std::string(tmpdata);
}

std::wstring string_to_wstring(const std::string& str)
{
	const size_t str_size = str.size();
	wchar_t* tmpdata = new wchar_t[str_size + 1];
	tmpdata[str_size] = 0;
	mbstowcs(tmpdata, str.c_str(), str_size);
	std::wstring str_res(tmpdata);
	delete[] tmpdata;
	return str_res;
}

#pragma warning (pop)

};